package com.gdust.hzx.product.controller;

import com.gdust.hzx.model.entity.product.Category;
import com.gdust.hzx.model.vo.common.Result;
import com.gdust.hzx.model.vo.common.ResultCodeEnum;
import com.gdust.hzx.product.service.CategoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

;

/**
 * ClassName: CategoryController
 * Package: com.gdust.hzx.product.controller
 * Description:分类接口开发控制层
 *
 * @Author syun
 * @Create 2024/12/26 10:08
 * @Version 1.0
 */
@Tag(name = "分类接口管理")
@RestController// @RestController: 专用于restful风格的注解 = @Controller (控制器) + @ResponseBody (方法返回值为json)
@RequestMapping(value="/api/product/category")
//@SuppressWarnings({"unchecked", "rawtypes"})
//@CrossOrigin //跨域
public class CategoryController {
    //注入商品分类表的service
    @Autowired
    private CategoryService categoryService;

    /**
     * 查询所有分类，树形封装
     * 思路：使用递归遍历树形结构
     * @return
     */
//    @Log(title = "查询所有分类，树形封装",businessType = 0,operatorType = OperatorType.MANAGE)
    @Operation(summary = "查询所有商品分类")
    @GetMapping("/findCategoryTree")
    public Result findCategoryTree(){
        //自定义查询：查询所有分类，树形封装
        List<Category> list = categoryService.findCategoryTree();
        return Result.build(list, ResultCodeEnum.SUCCESS);
    }


}
